/**
 * Created by John on 2016/5/5.
 */
var warn=$("#warn");
warn.hide();
$(document).ready(function(){
    $(".dl_style").on("click",function(){
        var username=$("#form-username").val();
        var pw=$("#form-password").val();
        if(!username){
            warnshow();
            warn.text("username不能为空");
            return;
        }
        if(!pw){
            warnshow();
            warn.text("password不能为空");
            return;
        }
        $.ajax({
            datatype:'json',
            method:'post',
            url:'/admin/loginadmin',
            data:{username:username,password:pw},
            success: function (data) {
                data=JSON.parse(data);
                console.log(data.status);
                console.log(data.exception);
                if(data.status==500){
                    warnshow();
                    warn.text(data.exception);
                }else{
                    sessionStorage.setItem("username",username);
                    window.location.href='index.html';
                }
            }
        })
    })
});
function warnshow(){
    warn.addClass("warn");
    warn.show();
}